home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 020a / djgdrv.zip / TSENG3K.ASM < prev    next >
Assembly Source File  |  1991-03-06  |  4KB  |  203 lines

  1. ; This is file TSENG3K.ASM
  2. ;
  3. ; Copyright (C) 1991 DJ Delorie, 24 Kirsten Ave, Rochester NH 03867-2954
  4. ;
  5. ; This file is distributed under the terms listed in the document
  6. ; "copying.dj", available from DJ Delorie at the address above.
  7. ; A copy of "copying.dj" should accompany this file; if not, a copy
  8. ; should be available from where this file was obtained.  This file
  9. ; may not be distributed without a verbatim copy of "copying.dj".
  10. ;
  11. ; This file is distributed WITHOUT ANY WARRANTY; without even the implied
  12. ; warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  13. ;
  14.  
  15. cseg    segment    byte public 'code'
  16.     assume    cs:cseg, ds:cseg, es:cseg, ss:nothing
  17.     .386p
  18.  
  19.     dw    offset init_routine
  20.     dw    offset paging_routine
  21.     dw    1    ; set to 1 if separate read & write windows or
  22.             ; only 64K of video RAM (ie: no paging)
  23.  
  24. def_tw    dw    80    ; filled in by go32 if GO32 env. var. is set
  25. def_th    dw    25
  26. def_gw    dw    640
  27. def_gh    dw    480
  28.  
  29. ;--------------------------------------------------------------------------
  30. ; Entry: AX=mode selection
  31. ;        0=80x25 text
  32. ;        1=default text
  33. ;        2=text CX cols by DX rows
  34. ;        3=biggest text
  35. ;        4=320x200 graphics
  36. ;        5=default graphics
  37. ;        6=graphics CX width by DX height
  38. ;        7=biggest non-interlaced graphics
  39. ;        8=biggest graphics
  40. ;
  41. ; NOTE: This runs in real mode, but don't mess with the segment registers.
  42. ;
  43. ; Exit:  CX=width (in pixels or characters)
  44. ;        DX=height
  45.  
  46. init_table    label    word
  47.     dw    offset init_0
  48.     dw    offset init_1
  49.     dw    offset init_2
  50.     dw    offset init_3
  51.     dw    offset init_4
  52.     dw    offset init_5
  53.     dw    offset init_6
  54.     dw    offset init_7
  55.     dw    offset init_8
  56.  
  57. init_routine    proc    far
  58.     cmp    ax,8
  59.     jbe    valid_req
  60.     ret
  61. valid_req:
  62.     shl    ax,1
  63.     mov    bx,ax
  64.     jmp    init_table[bx]
  65.  
  66. init_0: ; 80x25 text
  67.     mov    ax,3
  68.     int    10h
  69.     mov    cx,80
  70.     mov    dx,25
  71.     ret
  72.  
  73. init_1: ; default text
  74.     mov    cx,def_tw
  75.     mov    dx,def_th
  76.     jmp    init_2
  77.  
  78. init_2_table    label    word
  79.     dw    01h, 40, 25
  80.     dw    03h, 80, 25
  81.     dw    23h, 132, 25
  82.     dw    24h, 132, 28
  83.     dw    22h, 132, 44
  84.     dw    61h, 132, 50    ; not sure about some of these
  85. init_2_tend    label    word
  86.  
  87. init_2: ; CX*DX text
  88.     mov    si,offset init_2_table
  89. init_2a:
  90.     cmp    [si+2],cx
  91.     jb    init_2b
  92.     cmp    [si+4],dx
  93.     jb    init_2b
  94.     ; got a big enough one!
  95.     jmp    init_2c
  96. init_2b:
  97.     cmp    si,offset init_2_tend - 6
  98.     je    init_2c
  99.     add    si,6
  100.     jmp    init_2a
  101. init_2c:
  102.     mov    ax,[si]
  103.     push    si
  104.     int    10h
  105.     pop    si
  106.     mov    cx,[si+2]
  107.     mov    dx,[si+4]
  108.     ret
  109.  
  110. init_3: ; biggest text
  111.     mov    ax,[init_2_tend-6]
  112.     int    10h
  113.     mov    cx,[init_2_tend-4]
  114.     mov    dx,[init_2_tend-2]
  115.     ret
  116.  
  117. init_4: ; 320x200 graphics
  118.     mov    ax,13h
  119.     int    10h
  120.     mov    cx,320
  121.     mov    dx,200
  122.     ret
  123.  
  124. init_5: ; default graphics - should be 640x480 if supported
  125.     mov    cx,def_gw
  126.     mov    dx,def_gh
  127.     jmp    init_6
  128.  
  129. init_6_table    label    word
  130.     dw    13h, 320, 200
  131.     dw    2dh, 640, 350
  132.     dw    78h, 640, 400
  133.     dw    2eh, 640, 480
  134.     dw    30h, 800, 600
  135. init_6_tend    label    word
  136.  
  137. init_6: ; CX*DX graphics
  138.     mov    si,offset init_6_table
  139. init_6a:
  140.     cmp    [si+2],cx
  141.     jb    init_6b
  142.     cmp    [si+4],dx
  143.     jb    init_6b
  144.     ; got a big enough one!
  145.     jmp    init_6c
  146. init_6b:
  147.     cmp    si,offset init_6_tend - 6
  148.     je    init_6c
  149.     add    si,6
  150.     jmp    init_6a
  151. init_6c:
  152.     mov    ax,[si]
  153.     push    si
  154.     int    10h
  155.     pop    si
  156.     mov    cx,[si+2]
  157.     mov    dx,[si+4]
  158.     ret
  159.  
  160. init_7: ; biggest non-interlaced graphics
  161.     mov    ax,30h
  162.     int    10h
  163.     mov    cx,800
  164.     mov    dx,600
  165.     ret
  166.  
  167. init_8: ; biggest graphics
  168.     mov    ax,30h
  169.     int    10h
  170.     mov    cx,800
  171.     mov    dx,600
  172.     ret
  173.  
  174. init_routine    endp
  175.  
  176. ;--------------------------------------------------------------------------
  177. ; Entry: AH=read page
  178. ;        AL=write page
  179. ;
  180. ; NOTE: This runs in protected mode!  Don't mess with the segment registers!
  181. ; This code must be relocatable and may not reference any data!
  182. ;
  183. ; Exit: VGA configured.
  184. ;       AX,BX,CX,DX,SI,DI may be trashed
  185.  
  186.     assume    ds:nothing, es:nothing
  187.  
  188. paging_routine    proc    far
  189.     and    al,07h
  190.     and    ah,07h
  191.     shl    ah,3
  192.     or    al,ah
  193.     or    al,40h
  194.     mov    dx,03cdh
  195.     out    dx,al
  196.     ret
  197. paging_routine    endp
  198.  
  199. ;--------------------------------------------------------------------------
  200.  
  201. cseg    ends
  202.     end
  203.